#include "EditorScenePageModel.h"
#include "Window/EditorWindowGroupModel.h"
#include "Scene/SceneNode.h"
#include "Scene/Scene.h"
#include "Asset/AssetSubsystem.h"
TSharedObjectPtr<REditorPageModel> REditorScenePageModel::ShareClone(RObject *InOwner) const
{
    TSharedObjectPtr<REditorScenePageModel> NewModel = NewObject<REditorScenePageModel>(InOwner);
    NewModel->Scene = Scene;
    NewModel->FilePath = FilePath;
    NewModel->SelectedNode = SelectedNode;
    return NewModel;
}
void REditorScenePageModel::LowLevelSave()
{
    RAssetSubsystem::Get()->ResaveLoadedAsset(
        Scene
        ,nullptr
        ,nullptr);
}

TSharedObjectPtr<RObject> REditorScenePageModel::GetFocuseObject() const
{
    return GetSelectedNode();
}

TSharedObjectPtr<REditorScenePageModel> REditorScenePageModel::Create(const SPath& InFilePath,TSharedObjectPtr<RScene> InScene)
{
    TSharedObjectPtr<REditorScenePageModel> NewPageModel = NewObject<REditorScenePageModel>(REditorWindowGroupModel::Get());
    NewPageModel->Scene = InScene;
    NewPageModel->FilePath = InFilePath;

    return NewPageModel;
}

void REditorScenePageModel::SetSelectedNode(TSharedObjectPtr<RSceneNode> InNode)
{
    SelectedNode = InNode;
    NotifyFocusedObjectChanged();
}

TSharedObjectPtr<RSceneNode> REditorScenePageModel::GetSelectedNode() const
{
    return SelectedNode;
}

bool REditorScenePageModel::HasSelectedNode() const
{
    return SelectedNode.IsValid();
}
